package com.huawei.appmarket.framework.widget.uxwidget.topbanner;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import o.azb;
import o.dky.c;
import o.dky.h;
import o.dky.i;
import o.epr;
import o.epv;

public class TopBanner extends LinearLayout {
    private int ʻ;
    private boolean ʽ;
    private TextView ˊ;
    private ImageView ˋ;
    protected Context ˎ;
    private ImageView ˏ;
    private ImageView ॱ;
    private RelativeLayout ॱॱ;
    private RelativeLayout ᐝ;

    public TopBanner(Context context) {
        this(context, null);
    }

    public TopBanner(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public TopBanner(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ʽ = false;
        this.ˎ = context;
        this.ʽ = epr.ˎ().ॱॱ();
        ˏ(context, attributeSet);
    }

    protected int ˊ() {
        return i.ˊॱ;
    }

    protected int ˏ() {
        return this.ˎ.getResources().getDimensionPixelSize(c.ʼ);
    }

    public void ˏ(Context context, AttributeSet attributeSet) {
        LayoutInflater.from(context).inflate(ˊ(), this, true);
        this.ॱॱ = (RelativeLayout) findViewById(h.ʾ);
        this.ᐝ = (RelativeLayout) findViewById(h.ʻॱ);
        this.ʻ = getResources().getDisplayMetrics().widthPixels;
        this.ॱ = (ImageView) findViewById(h.ʽ);
        ˊ(this.ॱ, ˏ());
        this.ˏ = (ImageView) findViewById(h.ʼˊ);
        ˊ(this.ˏ, ˏ());
        this.ˋ = (ImageView) findViewById(h.ॱˋ);
        this.ˊ = (TextView) findViewById(h.ˋʽ);
        ʼ();
    }

    private void ˊ(View view, int i) {
        if (view.getLayoutParams() instanceof MarginLayoutParams) {
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) view.getLayoutParams();
            marginLayoutParams.bottomMargin = i;
            view.setLayoutParams(marginLayoutParams);
        }
    }

    private void ʼ() {
        if (!this.ʽ) {
            return;
        }
        if (azb.ˎ(this.ˎ)) {
            setCommodityPara(0.4f, this.ʻ);
        } else {
            setCommodityPara(0.7f, this.ʻ);
        }
    }

    public void setCommodityPara(float f, int i) {
        if (this.ˋ != null && (this.ˋ.getLayoutParams() instanceof LayoutParams)) {
            LayoutParams layoutParams = (LayoutParams) this.ˋ.getLayoutParams();
            if (i != 0) {
                layoutParams.width = (int) (((((float) i) * f) * 52.0f) / 328.0f);
                layoutParams.height = (int) (((((float) i) * f) * 52.0f) / 328.0f);
                this.ˋ.setLayoutParams(layoutParams);
            }
        }
    }

    public void setLeftView2(float f) {
        if (epv.ʼ(this.ˎ)) {
            ॱ(f);
        } else if (((double) f) < 0.25d) {
            this.ᐝ.setX((float) (((double) (((float) this.ʻ) * f)) * 0.2d));
            this.ॱॱ.setX(0.0f);
            this.ˏ.setX((float) (((double) (((float) this.ʻ) * f)) * 0.5d));
        } else {
            this.ᐝ.setX((float) ((((double) ((1.0f - f) * ((float) this.ʻ))) * 1.0d) / 15.0d));
            this.ॱॱ.setX(0.0f);
            this.ˏ.setX((float) ((((double) ((1.0f - f) * ((float) this.ʻ))) * 1.0d) / 6.0d));
        }
    }

    public void ॱ(float f) {
        this.ᐝ.setX((float) (((double) ((1.0f - f) * ((float) this.ʻ))) * 0.06d));
        this.ॱॱ.setX(0.0f);
        this.ˏ.setX((float) (((double) ((1.0f - f) * ((float) this.ʻ))) * 0.9d));
    }

    public void setRightView1(float f) {
        if (epv.ʼ(this.ˎ)) {
            ˏ(f);
        } else if (((double) f) < 0.25d) {
            this.ᐝ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.2d));
            this.ॱॱ.setX(0.0f);
            this.ˏ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.5d));
        } else {
            this.ᐝ.setX((float) ((((double) ((f - 1.0f) * ((float) this.ʻ))) * 1.0d) / 15.0d));
            this.ॱॱ.setX(0.0f);
            this.ˏ.setX((float) ((((double) ((f - 1.0f) * ((float) this.ʻ))) * 1.0d) / 6.0d));
        }
    }

    public void ˏ(float f) {
        this.ᐝ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.5d));
        this.ॱॱ.setX(0.0f);
        this.ˏ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.2d));
    }

    public void setLeftView1(float f) {
        this.ᐝ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.6d));
        this.ॱॱ.setX(0.0f);
        this.ˏ.setX((float) (((double) ((-f) * ((float) this.ʻ))) * 0.1d));
    }

    public void setRightView2(float f) {
        this.ᐝ.setX((float) (((double) ((1.0f - f) * ((float) this.ʻ))) * 0.6d));
        this.ॱॱ.setX(0.0f);
        this.ˏ.setX((float) (((double) ((1.0f - f) * ((float) this.ʻ))) * 0.4d));
    }

    public void setInitialPosition() {
        this.ᐝ.setX(0.0f);
        this.ॱॱ.setX(0.0f);
        this.ˏ.setX(0.0f);
    }

    protected void ॱ(int i) {
        LayoutParams layoutParams = (LayoutParams) this.ˊ.getLayoutParams();
        if (layoutParams != null) {
            layoutParams.bottomMargin -= i;
            this.ˊ.setLayoutParams(layoutParams);
        }
    }

    public ImageView ॱ() {
        return this.ॱ;
    }

    public ImageView ˋ() {
        return this.ˏ;
    }

    public ImageView ˎ() {
        return this.ˋ;
    }

    public TextView ʻ() {
        return this.ˊ;
    }
}
